{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "一般性的统计指标的计算方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入NumPy库\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "数据加载"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 创建一个包含随机数据的NumPy数组\n",
    "data = np.array([12, 15, 18, 22, 30, 35, 40, 42, 50, 58])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "平均值 (Mean): 32.2\n"
     ]
    }
   ],
   "source": [
    "# 计算平均值\n",
    "mean = np.mean(data)\n",
    "print(\"平均值 (Mean):\", mean)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "方差 (Variance): 216.16000000000003\n"
     ]
    }
   ],
   "source": [
    "# 计算方差\n",
    "variance = np.var(data)\n",
    "print(\"方差 (Variance):\", variance)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "标准差 (Standard Deviation): 14.702380759591286\n"
     ]
    }
   ],
   "source": [
    "# 计算标准差\n",
    "std_deviation = np.std(data)\n",
    "print(\"标准差 (Standard Deviation):\", std_deviation)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "my_env",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
